<template>
	<view class="body">
		<view class="sticky-top">
			<view class="header-title">提交审核成功</view>
			<view class="header-title2">系统将在1-3个工作日内完成审核</view>
			<image class="audit-style" :src="model.reviewState === 1? bImg2 : model.reviewState === 3?bImg4:bImg3"></image>
		</view>
		<u-form
		  :model="model"
		  label-width="150"
		  :label-position="labelPosition"
		>
		  <u-form-item label="工厂名称">
			  {{model.factoryName}}
		  </u-form-item>
		  <u-form-item label="工厂简介">
			  {{model.description}}
		  </u-form-item>
		  <u-form-item label="工厂地址">
			   {{model.address.provinceName+model.address.cityName+model.address.countyName+model.address.detailStreet}}
		  </u-form-item>
		  <u-form-item label="收货地址">
			    {{model.warehouseAddress.provinceName+model.warehouseAddress.cityName+model.warehouseAddress.countyName+model.warehouseAddress.detailStreet}}
		  </u-form-item>
		  <u-form-item label="车缝人数">
			   {{model.factoryScale.min +'-'+model.factoryScale.max}}
		  </u-form-item>
		  <u-form-item label="营业执照">
		    <view class="uni-padding-wrap uni-common-mt10">
		      <view class="demo">
		        <block>
		          <image  :src="'http://files.ybangy.net/'+model.businessLicenseImg" class="image" mode="widthFix"></image>
		        </block>
		      </view>
		    </view>
		  </u-form-item>
		  <u-form-item label="认证人姓名">
			   {{model.chargePerson}}
		  </u-form-item>
		  <u-form-item label="收货人姓名">
			   {{model.warehouseChargePerson}}
		  </u-form-item>
		  <u-form-item label="收货人手机">
			   {{model.warehouseChargePersonTel}}
		  </u-form-item>
		  <u-form-item label="联系人身份证">
		    <view class="uni-padding-wrap uni-common-mt10">
		      <view class="demo">
		        <block>
		          <image :src="'http://files.ybangy.net/'+model.idCardFrontImg" class="image" mode="widthFix"></image>
		        </block>
		      </view>
		    </view>
		    <view class="uni-padding-wrap uni-common-mt10">
		      <view class="demo">
		        <block>
		          <image :src="'http://files.ybangy.net/'+model.idCardBackImg" class="image" mode="widthFix"></image>
		        </block>
		      </view>
		    </view>
		  </u-form-item>
		  <u-form-item label="擅长类目">
			  <text>{{ model.wellCategory.join(',') }}</text>
		  </u-form-item>
		  <u-form-item label="加工模式">
			  <text>{{ model.productPattern.join(',') }}</text>
		  </u-form-item>
		</u-form>
		<view class="u-f-ajc u-f-jsb">
			<button
			  style="width: 35%;"
			  class="user-set-btn"
			  @tap="backOut"
			>
			  退出
			</button>
			<button
			  style="width: 35%;"
			  class="user-set-btn"
			  @tap="refresh"
			>
			  刷新
			</button>
		</view>
		<u-modal v-model="successShowMsg" @confirm="confirmBtn" :content="successContentMsg" :show-title="false" :show-cancel-button="true" :cancel-text="cancelText" :confirm-text="confirmText" :content-style="modalstyleObj" :cancel-style="modalstyleObj" :confirm-style="{color: '#5880FF',fontSize:'30upx',fontWeight:'700'}"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				successShowMsg:false,
				successContentMsg:'',
				cancelText:'取消',
				confirmText:'',
				modalstyleObj:{color: '#333333',fontSize:'30upx',fontWeight:'700'},
				bImg2: require('../../static/image/audit2.png'),
				bImg3: require('../../static/image/audit3.png'),
				bImg4: require('../../static/image/audit4.png'),
				model: {
				  factoryName: '', 
				  description: '', 
				  address:{
					  provinceName:'',
					  cityName:'',
					  countyName:'',
					  detailStreet:''
				  },
				  warehouseAddress:{
					  provinceName:'',
					  cityName:'',
					  countyName:'',
					  detailStreet:''
				  },
				  factoryScale:{
					  min:null,
					  max:null
				  },
				  businessLicenseImg: '', //营业执照
				  chargePerson: '', //认证人姓名
				  warehouseChargePerson: '', //收货人姓名
				  warehouseChargePersonTel: '', //收货人手机号
				  idCardFrontImg: '', //身份证正面照
				  idCardBackImg: '', //身份证反面照
				  wellCategory: [], //擅长品类
				  productPattern: [], //生产模式
				},
			};
		},
		onLoad(options){
			uni.hideHomeButton()
			// 判断获取变量的类型是否为字符串
			if ((typeof options.auditInfo) === 'string') {
			    // 调用JSON.parse()方法将字符串转换成json格式
				let infoObj = JSON.parse(options.auditInfo)
				this.model = infoObj
				console.log(JSON.parse(options.auditInfo),'audit')
			}
			this.stateIsShowModal(this.model.reviewState)
		},
		onShow() {
		},
		methods:{
			stateIsShowModal(reviewState){
				if(reviewState === 2){
					this.successShowMsg = true
					this.successContentMsg = '审核成功'
					this.confirmText = '去首页'
				}else if(reviewState === 3){
					this.successShowMsg = true
					this.successContentMsg = '审核失败'
					this.confirmText = '重新认证'
				}
			},
			confirmBtn(){
				console.log(this.model)
				if(this.model.reviewState === 2){
					//审核成功去首页
					uni.switchTab({
					    url: '/pages/index/index'
					});
				}else {
					//审核失败重新认证
					uni.redirectTo({
					    url:'/pages/authentication/authentication'
					});
				}

			},
			//退出
			backOut(){
				uni.removeStorageSync('token')
				uni.removeStorageSync('userInfo')
				uni.removeStorageSync('factoryinfo')
				uni.reLaunch({
				    url: '/pages/login/login'
				});
			},
			//刷新（获取最新的审核状态）
			refresh(){
				this.$store.dispatch('getCurrentFactory').then(res=>{
					if(res.data.errorCode === 0){
						this.model = JSON.parse(JSON.stringify(res.data.data))
						this.stateIsShowModal(this.model.reviewState)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page {
	background-color: #fff;
}
.body{
	padding: 0 30upx 20upx!important;
	.sticky-top{
		width:100%;
		position:sticky;
		position: -webkit-sticky;
		top: 0;
		padding-bottom: 10rpx;
		background-color: #fff;
		z-index: 999;
		.header-title{
		  margin-top: 10upx;
		  font-size: 50upx;
		  font-weight: 700;
		  line-height: 90upx;
		}
		.header-title2{
			color: #666;
			font-size: 32upx;
		}
		.audit-style{
			width: 88px!important;
			height: 66px!important;
			position: absolute;
			right: 0;
			top: 0;
		}
	}
	image{
		  width: 345px!important;
		  height: 188px!important;
	}

}	
</style>
